package ai.loa.utility;

import java.util.HashSet;
import java.util.Set;

//classe cella usata per il grafo-scacchiera
public class Cell {
	public int x;
	public int y;
	public boolean visitato;

	public String id;
	public Set<Cell> neighbours;

	public Cell(int x, int y) {
		id = "" + x + y;
		neighbours = new HashSet<Cell>();
		this.x = x;
		this.y = y;
		visitato = false;
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + ((id == null) ? 0 : id.hashCode());
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		Cell other = (Cell) obj;
		if (id == null) {
			if (other.id != null)
				return false;
		} else if (!id.equals(other.id))
			return false;
		return true;
	}

	@Override
	public String toString() {
		String s = "Cell [id=" + id + ", neighbours={";
		for (Cell c : neighbours) {
			s += c.id;
			s += ";";
		}
		s += "}]";
		return s;
	}

}
